home *** CD-ROM | disk | FTP | other *** search
-
- ;GETFLEN.ASM
- ;
- ;6.12.85
-
- comment ~
-
- Get file length
-
- On entry:
- DX address of dpathfilename.ext ASCIIZ string
-
- On exit:
- losiz file size: low word
- hisiz file size: high word
-
- Error returns if CY is set:
- 1 invalid function number
- 6 invalid handle
-
- Uses:
-
- Notes:
-
- ~
-
- ;----------------------------------------------------------
- ; constants and messages
-
- gflen_msg db cr,lf,'getflen: ',eos
-
- ;----------------------------------------------------------
- ; data storage
-
- losiz dw 0 ;file size: low word
- hisiz dw 0 ;file size: high word
-
- ;----------------------------------------------------------
- ; main code section
-
- GETFLEN proc near
-
- ;open the file:
- ;DX has offset to ASCIIZ on entry
- mov ax,3d00h ;open for read function combo
- int 21h
- jc gflen_err
- mov bx,ax ;handle to BX
-
- get_file_space:
- xor cx,cx ;zero offset..
- xor dx,dx ;..zero most significant part of offset
- mov al,2 ;move to end of file plus zero offset
- ;BX has handle
- mov ah,42H ;use lseek to find end of file
- int 21H
- jc gflen_err
-
-
- mov hisiz,dx ;msw in hisiz
- mov losiz,ax ;lsw in losiz
-
- ;close the file:
- ;BX has handle
- mov ah,3eh ;close file handle function call
- int 21h
- jc gflen_err
- ret
-
- gflen_err:
- push ax ;save error code
- mov dx,offset gflen_msg
- mov ah,9h ;print string function call
- int 21h
- pop ax
- call errmsg
- stc
- ret
-
- getflen endp
-